package com.df.blueben.controller;
import com.df.blueben.common.BaseResponse;
import com.df.blueben.common.ResultUtils;
import com.df.blueben.model.dto.UserLoginDto;
import com.df.blueben.model.dto.UserRegisterDto;
import com.df.blueben.model.vo.UserVo;
import com.df.blueben.service.UsersService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    UsersService usersService;
    @PostMapping("/login")
    BaseResponse<UserVo> userLogin(@RequestBody UserLoginDto userLoginDto){
        UserVo userVo = usersService.userLogin(userLoginDto);
        return ResultUtils.success(userVo);
    }

    @PostMapping("/register")
    BaseResponse<Integer> userRegister(@RequestBody UserRegisterDto userRegisterDto){
        Integer userId = usersService.userRegister(userRegisterDto);
        return ResultUtils.success(userId);
    }
}
